<template>
  <div class="template-index-Lu">
    <commpVxeTable
      :key="reCommpVxeTable"
      :conditionBtnRow="true"
      :config="dataTableConfig"
      :columns="columnsVxe"
      :formItem="formItem"
      ref="administrativeOffice"
      @searchEvent="searchEvent"
      @resetEvent="resetEvent"
      >
      <template v-slot:operation_realname="{row}" data-desc="姓名">
            <span style="padding-right: 21;" v-if="row.fuserName.length == 2">
                <span v-for="(trem,tI) in row.fuserName.split('')" :key="tI" >
                    {{trem}}
                    <span v-if="tI+1 !== row.fuserName.split('').length">&nbsp;&nbsp;</span>
                </span>
            </span>
            <span style="padding-right: 21;" v-else>{{ row.fuserName }}</span>
        </template>
        <template v-slot:operation_fnd>
          <a-date-picker
                v-model="year"
                type="year"
                mode="year"
                format="YYYY"
                placeholder="请输入年份"
                @panelChange="panelChangeOne" />
        </template>
    </commpVxeTable>
  </div>
</template>
<script>
import assessCheckApi from './service/api.js'
import commpVxeTable from '@/components/commp-vxe-table/commp-vxe-table.vue'
import {logsList} from './service/index'
import moment from 'moment'
export default {
  components: {
    commpVxeTable
  },
  data() {
    return {
      reCommpVxeTable: '',
      moment,
      year: null,
      dataTableConfig: {
        api: assessCheckApi.logsList,
        rowId: 'id',
        urlType: true,
        paramet: {}
      },
      columnsVxe:[
        {
          title: '姓名',
          field: 'fuserName',
          width: 100,
          titleInterval:true,
          slots: {
              header:'data1_header',
              default: 'operation_realname',
          }
        },{
          title: '参加工作时间',
          field: 'fcjgzsj',
        },{
          title: '工龄',
          field: 'fgl',
          width: 80,
          titleInterval:true,
          slots: {
              header:'data2_header',
          }
        },{
          title: '年度',
          field: 'fnd',
        },
      ],
      formItem: [
        {
          label: '姓名',
          model: 'fuserName',
        },{
          label: '年度',
          model: 'fnd',
          slotName:'operation_fnd'
        },
      ],
      idList: [],
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList(){
      logsList().then(res => {
        let list = res.result.records
        list.forEach(item => {
          this.idList.push(item.id)
        })
      })
    },
    // 得到年份选择器的值
    panelChangeOne(value) {
      this.year = moment(value).format('YYYY')
      this.dataTableConfig.paramet = {
        fnd: moment(value).format('YYYY')
      }
      this.reCommpVxeTable = Date.now()
    },
    // 搜索
    searchEvent(){
      this.dataTableConfig.paramet = {
        ...this.dataTableConfig.paramet,
      }
      //console.log(this.dataTableConfig.paramet)
    },
    // 重置
    resetEvent(){
      this.dataTableConfig.paramet = {
        ...this.dataTableConfig.paramet,
      }
    },
  },
}
</script>
<style>
@import url('../../css/oaClass.css');
</style>
